package sm;

import java.io.File;
import java.io.IOException;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Layout;
import org.apache.log4j.PatternLayout;

public class Log4jUtil {
    public  static FileAppender getFileAppender(String file){
        File f= new File(file);
        if( ! f.getAbsoluteFile().getParentFile().exists() ) f.getAbsoluteFile().getParentFile().mkdirs();
        FileAppender appender = new FileAppender();

        Layout layout = new PatternLayout("%m%n"); 
        appender.setLayout(layout);
        appender.setFile(f.getAbsolutePath());
        ((FileAppender)appender).activateOptions();  
        return appender ;
    }
}
